<!DOCTYPE>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<head>
	<meta charset="utf-8">
	<title>登录页</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<link href="__PUBLIC__/css/login.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/jquery.SuperSlide.2.1.2.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/jquery.validation.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/jquery.cookie.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/gt.js"></script>
	<style>
		#embed-captcha {
			width: 700px;
			margin: 0 auto;
		}
	</style>
	<script type="text/javascript">
		//若cookie值不存在，则跳出iframe框架
		// if(!$.cookie('tpshopActionParam') && $.cookie('admin_type') != 1){
		// 	$.cookie('admin_type','1' , {expires: 1 ,path:'/'});
		// 	//top.location.href = location.href;
		// }
	</script>
</head>
<body>
<div class="login_left">
	<div class="login_lt_cont"> <img src="__PUBLIC__/images/erweima.png">
		<p>小马出行微信公众号</p>
	</div>
</div>
<div class="login_right">
	<div class="login_rt_cont">
		<div class="login_rt_title"> <img src="__PUBLIC__/images/logo.png">
			<h1>综合管理平台</h1>
		</div>
		<div class="login_rt_box">
			<form action="" name='theForm' id="theForm" method="post">
				<div class="login_title"> <span class="title">账号</span>
					<div class="login_input">
						<i class="icon_ic icon_ic1"></i>

						<input type="text" name="username" autocomplete="off" class="long" value="" placeholder="用户名" />
					</div>
				</div>
				<div class="login_title"> <span class="title">密码</span>
					<div class="login_input">
						<i class="icon_ic icon_ic2"></i>

						<input type="password" name="password" autocomplete="off" class="long" value="" placeholder="密  码" />
					</div>
				</div>
				<div style="width: 28px;height: 28px;background: #f9f9f9;position: absolute;right: 108px;bottom: 150px; z-index:9999;"></div>
				<div class="login_title"> <span class="title">极验</span>
					<div class="login_input">
						<div id="embed-captcha"></div>
						<p id="wait" class="show"></p>
						<p id="notice" class="hide"></p>
					</div>
				</div>
				<div class="login_btn">
					<input type="button" name="submit" id="embed-submit" class="btn" value="登录">
				</div>
			</form>
		</div>

	</div>
	<div class="login_rt_footer">
		<p>©2018 好马科技  Version 3.0.0</p>
	</div>
</div>

<!--<script type="text/javascript" src="js/jquery.purebox.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>
<script type="text/javascript">
	$("#bannerBox").slide({mainCell:".slideBanner",effect:"fold",interTime:3500,delayTime:500,autoPlay:true,autoPage:true,endFun:function(i,c,s){
			$(window).resize(function(){
				var width = $(window).width();
				var height = $(window).height();
				s.find(".slideBanner,.slideBanner li").css({"width":width,"height":height});
			});
		}});

	$(function(){
		$(".formText .input-text").focus(function(){
			$(this).parent().addClass("focus");
		});

		$(".formText .input-text").blur(function(){
			$(this).parent().removeClass("focus");
		});

		$(".checkbox").click(function(){
			if($(this).hasClass("checked")){
				$(this).removeClass("checked");
				$('input[name=remember]').val(0);
			}else{
				$(this).addClass("checked");
				$('input[name=remember]').val(1);
			}
		});

		$(".formText .input-yzm").focus(function(){
			$(this).prev().show();
		});

		$(".formText").blur(function(){
			$(this).prev().hide();
		});
	});

	$(function(){
		$(document).keyup(function(event){
			if(event.keyCode ==13){
				$('#theForm input[name=submit]').trigger("click");
			}
		});

		$('#theForm input[name=submit]').on('click',function(){
			var username=true;
			var password=true;
			var vertify=true;

			if($('#theForm input[name=username]').val() == ''){
				layer.msg('用户名不能为空',{icon:2});
				//$('#error').html('<span class="error">用户名不能为空!</span>');
				$('#theForm input[name=username]').focus();
				username = false;
				return false;
			}


			if($('#theForm input[name=password]').val() == ''){
				layer.msg('密码不能为空!',{icon:2});

				$('#theForm input[name=password]').focus();
				password = false;
				return false;
			}

			// 对密码进行MD5加密
			password = $('#theForm input[name=password]').val();

			// 定义密码要求的正则表达式
			var regex=/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{6,}$/;
			if (regex.test(password) == false) {
				layer.msg('密码必须由大小写+特殊字符+数字组合!',{icon:2});
				password = false;
				return false;
			}
			password = CryptoJS.MD5(password).toString();


			if(vertify && $('#theForm input[name=username]').val() != '' && $('#theForm input[name=password]').val() != ''){

				$.ajax({
					//    async:false,
					url:"{:url('Admin/login')}",
					data:{'username':$('#theForm input[name=username]').val(),'password':password,'geetest_validate':$('#theForm input[name=geetest_validate]').val(),'geetest_challenge':$('#theForm input[name=geetest_challenge]').val(),'geetest_seccode':$('#theForm input[name=geetest_seccode]').val()},
					type:'post',
					dataType:'json',
					success:function(data){
						if(data.status != 1){
							layer.msg(data.msg,{icon:2});
							// $('#error').html('<span class="error">'+data.msg+'!</span>');
							username=false;
							password=false;
							return false;
						}else{
							window.location.href = data.url;
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						$('#error').html('<span class="error">网络失败，请刷新页面后重试!</span>');
					}
				});
			}else{
				return false;
			}
		});

		$(document).click(function(e){
			if(e.target.name !='vertify' && !$(e.target).parents("div").is(".submitDiv")){
				$('.code').hide();
			}
		});
	});

</script>
<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.js"></script>
<script>
	var handlerEmbed = function (captchaObj) {
		$("#embed-submit").click(function (e) {
			var validate = captchaObj.getValidate();
			console.log("validate")
			console.log(validate)
			if (!validate) {
				$("#notice")[0].className = "show";
				setTimeout(function () {
					$("#notice")[0].className = "hide";
				}, 2000);
				e.preventDefault();
			}
		});
		// 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
		captchaObj.appendTo("#embed-captcha");
		captchaObj.onReady(function () {
			$("#wait")[0].className = "hide";
		});
	};
	$.ajax({
		// 获取id，challenge，success（是否启用failback）
		url: "/admin/admin/jy?t=" + (new Date()).getTime(), // 加随机数防止缓存
		type: "get",
		dataType: "json",
		success: function (data) {

			// 使用initGeetest接口
			// 参数1：配置参数
			// 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
			initGeetest({
				gt: data.gt,
				challenge: data.challenge,
				new_captcha: data.new_captcha,
				product: "embed", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
				offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
			}, handlerEmbed);
		}
	});
</script>
</body>
</html>
